#include <QtGui> 
#include <iostream>
#include "login.h"
#include "User.hpp"
#include "BusinessLogic.hpp"
 
login::login(QWidget *parent)
{
    setupUi(this); // this sets up GUI
 
    // signals/slots mechanism in action
    connect( pushButton_login, SIGNAL( clicked() ), this, 
            SLOT( loginConfirm() ) ); 
}

void login::loginConfirm()
{
    string name = lineEdit_id->text().toStdString();
    string pwd = lineEdit_pwd->text().toStdString();
    cout << "name: " << name << " password: " << pwd << endl;
    User *user = new User(name, pwd);
    BusinessLogic* bl = BusinessLogic::singleton();
    LoginStatus status = bl->login(user);
    if (status == LoginSuccess)
    {
        portalBar *p = new portalBar();
        p->move(0,0);
        p->show();
        p->raise();
        p->activateWindow();
        this->close();
    }
}
